package net.araim.bbingo;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;
import android.widget.TextView;

public class BingoTextView extends TextView {

	private boolean checked;

	public BingoTextView(Context c) {
		super(c);
	}

	public boolean isChecked(){
		return checked;
	}
	
	public void check() {
		this.checked = true;
	}

	public void uncheck() {
		this.checked = false;
		
	}
	
	public void uncheckAndReset(){
		uncheck();
		setBackgroundColor(Color.BLACK);
		setTextColor(Color.LTGRAY);
		((View)getParent()).setBackgroundColor(Color.WHITE);
		invalidate();
	}

	@Override
	public void setBackgroundColor(int color) {
		// TODO Auto-generated method stub
		super.setBackgroundColor(color);
	}
	
	@Override
	public void draw(Canvas c) {
		super.draw(c);
	
		if (checked) {
			Paint p = new Paint();
			p.setColor(10027008); // #999999
			p.setStyle(Paint.Style.STROKE);
			p.setAlpha(110);
			p.setStrokeWidth(2.2f);
			p.setAntiAlias(true);

//			c.drawLine(this.getLeft()+crossOffsett, this.getBottom()-crossOffsett, this.getRight()-crossOffsett, this
//					.getTop()+crossOffsett, p);
//			c.drawLine(this.getRight()-crossOffsett, this.getBottom()-crossOffsett, this.getLeft()+crossOffsett, this
//					.getTop()
//					+ crossOffsett, p);
			
			Bitmap b = BitmapFactory.decodeResource(this.getResources(), R.drawable.starblack48);
			c.drawBitmap(b, (this.getRight() - 48) /2, (this.getBottom()-48)/2, p);
		}
	}
}
